import type{FlatCategory,TreeNode} from '../../types'
export function buildTree(
  flatData: FlatCategory[],
  parentId: string = '0'
): TreeNode[] {
  return flatData
    .filter(item => item.parentId === parentId)
    .map(item => ({
      value: item.id.toString(),
      label: item.name,
      children: buildTree(flatData, item.id) // 递归处理子节点
    }));
}